﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SARControlLib
{
	
    /// <summary>
    /// 类似开始计算这样的一个按钮
    /// </summary>
    public partial class SAR_BigButton : UserControl
    {
        public SAR_BigButton()
        {
            InitializeComponent();
        }

        private string windowsTxt;

        /// <summary>
        /// 按钮上显示的文本
        /// </summary>
        public string SARWindowsText
        {
            get
            {
                windowsTxt = this.TextFiled.Text;
                return windowsTxt;
            }
            set
            {
                windowsTxt = value;
                this.TextFiled.Text = windowsTxt;
            }
        }

        /// <summary>
        /// 按钮被单击事件
        /// </summary>
        public event MouseButtonEventHandler SARBigBtnClick;

        private void bigBtn_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!isEnabled)
            {
                return;
            }

            this.TextFiled.Margin = new Thickness(19, 8, 0, 0);

            if (SARBigBtnClick != null)
            {
                SARBigBtnClick.Invoke(this, e);
            }
        }

        private bool isEnabled = true;

        /// <summary>
        /// 按钮是否处于启用状态
        /// </summary>
        public bool SARIsEnabled
        {
            set
            {
                isEnabled = value;
                if (isEnabled)
                {
                    this.Opacity = 1;
                }
                else
                {
                    this.Opacity = 0.5;
                }
            }
            get
            {
                return isEnabled;
            }
        }

        private void bigBtn_MouseLeave(object sender, MouseEventArgs e)
        {
            if (!isEnabled)
            {
                return;
            }

            this.TextFiled.Margin = new Thickness(18, 7, 0, 0);
        }

        private void bigBtn_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!isEnabled)
            {
                return;
            }

            this.TextFiled.Margin = new Thickness(18, 7, 0, 0);
        }
    }
}